package com.ruoyi.report_jl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.syrw.annotation.FIllBasicInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.ruoyi.report_jl.domain.bo.ReportJlKfsxzssyjlbBsInfoBo;
import com.ruoyi.report_jl.domain.vo.ReportJlKfsxzssyjlbBsInfoVo;
import com.ruoyi.report_jl.domain.ReportJlKfsxzssyjlbBsInfo;
import com.ruoyi.report_jl.mapper.ReportJlKfsxzssyjlbBsInfoMapper;
import com.ruoyi.report_jl.service.IReportJlKfsxzssyjlbBsInfoService;

import java.util.List;
import java.util.Map;
import java.util.Collection;

/**
 * 矿粉塑性指数试验检测记录Service业务层处理 - 弃用
 *
 * @author tll
 * @date 2024-06-28
 */
@RequiredArgsConstructor
@Service
public class ReportJlKfsxzssyjlbBsInfoServiceImpl implements IReportJlKfsxzssyjlbBsInfoService {

    private final ReportJlKfsxzssyjlbBsInfoMapper baseMapper;

    /**
     * 查询矿粉塑性指数试验检测记录
     */
    @Override
    @FIllBasicInfo
    public ReportJlKfsxzssyjlbBsInfoVo queryById(Long excelId){
        return baseMapper.selectVoById(excelId);
    }

    /**
     * 查询矿粉塑性指数试验检测记录列表
     */
    @Override
    public TableDataInfo<ReportJlKfsxzssyjlbBsInfoVo> queryPageList(ReportJlKfsxzssyjlbBsInfoBo bo, PageQuery pageQuery) {
        LambdaQueryWrapper<ReportJlKfsxzssyjlbBsInfo> lqw = buildQueryWrapper(bo);
        Page<ReportJlKfsxzssyjlbBsInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
        return TableDataInfo.build(result);
    }

    /**
     * 查询矿粉塑性指数试验检测记录列表
     */
    @Override
    public List<ReportJlKfsxzssyjlbBsInfoVo> queryList(ReportJlKfsxzssyjlbBsInfoBo bo) {
        LambdaQueryWrapper<ReportJlKfsxzssyjlbBsInfo> lqw = buildQueryWrapper(bo);
        return baseMapper.selectVoList(lqw);
    }

    private LambdaQueryWrapper<ReportJlKfsxzssyjlbBsInfo> buildQueryWrapper(ReportJlKfsxzssyjlbBsInfoBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportJlKfsxzssyjlbBsInfo> lqw = Wrappers.lambdaQuery();
        lqw.eq(bo.getTotalPage() != null, ReportJlKfsxzssyjlbBsInfo::getTotalPage, bo.getTotalPage());
        lqw.eq(bo.getPage() != null, ReportJlKfsxzssyjlbBsInfo::getPage, bo.getPage());
        lqw.eq(StringUtils.isNotBlank(bo.getJilbh()), ReportJlKfsxzssyjlbBsInfo::getJilbh, bo.getJilbh());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancdwmc()), ReportJlKfsxzssyjlbBsInfo::getJiancdwmc, bo.getJiancdwmc());
        lqw.eq(StringUtils.isNotBlank(bo.getGongcbwyt()), ReportJlKfsxzssyjlbBsInfo::getGongcbwyt, bo.getGongcbwyt());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpmc()), ReportJlKfsxzssyjlbBsInfo::getYangpmc, bo.getYangpmc());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpbh()), ReportJlKfsxzssyjlbBsInfo::getYangpbh, bo.getYangpbh());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpsl()), ReportJlKfsxzssyjlbBsInfo::getYangpsl, bo.getYangpsl());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpzt()), ReportJlKfsxzssyjlbBsInfo::getYangpzt, bo.getYangpzt());
        lqw.eq(bo.getYangpsj() != null, ReportJlKfsxzssyjlbBsInfo::getYangpsj, bo.getYangpsj());
        lqw.eq(StringUtils.isNotBlank(bo.getShiyjcrq()), ReportJlKfsxzssyjlbBsInfo::getShiyjcrq, bo.getShiyjcrq());
        lqw.eq(StringUtils.isNotBlank(bo.getShiytjwd()), ReportJlKfsxzssyjlbBsInfo::getShiytjwd, bo.getShiytjwd());
        lqw.eq(StringUtils.isNotBlank(bo.getShiytjsd()), ReportJlKfsxzssyjlbBsInfo::getShiytjsd, bo.getShiytjsd());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancyj()), ReportJlKfsxzssyjlbBsInfo::getJiancyj, bo.getJiancyj());
        lqw.eq(StringUtils.isNotBlank(bo.getPandyj()), ReportJlKfsxzssyjlbBsInfo::getPandyj, bo.getPandyj());
        lqw.eq(StringUtils.isNotBlank(bo.getZhuyyqsbmcjbh()), ReportJlKfsxzssyjlbBsInfo::getZhuyyqsbmcjbh, bo.getZhuyyqsbmcjbh());
        lqw.eq(StringUtils.isNotBlank(bo.getFujsm()), ReportJlKfsxzssyjlbBsInfo::getFujsm, bo.getFujsm());
        lqw.eq(StringUtils.isNotBlank(bo.getBaobmc()), ReportJlKfsxzssyjlbBsInfo::getBaobmc, bo.getBaobmc());
        lqw.eq(StringUtils.isNotBlank(bo.getBaobbh()), ReportJlKfsxzssyjlbBsInfo::getBaobbh, bo.getBaobbh());
        lqw.eq(StringUtils.isNotBlank(bo.getGongcmc()), ReportJlKfsxzssyjlbBsInfo::getGongcmc, bo.getGongcmc());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancr()), ReportJlKfsxzssyjlbBsInfo::getJiancr, bo.getJiancr());
        lqw.eq(StringUtils.isNotBlank(bo.getJilr()), ReportJlKfsxzssyjlbBsInfo::getJilr, bo.getJilr());
        lqw.eq(StringUtils.isNotBlank(bo.getFuhr()), ReportJlKfsxzssyjlbBsInfo::getFuhr, bo.getFuhr());
        lqw.eq(bo.getRiq() != null, ReportJlKfsxzssyjlbBsInfo::getRiq, bo.getRiq());
        lqw.eq(StringUtils.isNotBlank(bo.getShebIds()), ReportJlKfsxzssyjlbBsInfo::getShebIds, bo.getShebIds());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancyjIds()), ReportJlKfsxzssyjlbBsInfo::getJiancyjIds, bo.getJiancyjIds());
        lqw.eq(StringUtils.isNotBlank(bo.getPandyjIds()), ReportJlKfsxzssyjlbBsInfo::getPandyjIds, bo.getPandyjIds());
        lqw.eq(bo.getZhuirsdH1Group1() != null, ReportJlKfsxzssyjlbBsInfo::getZhuirsdH1Group1, bo.getZhuirsdH1Group1());
        lqw.eq(bo.getZhuirsdH1Group2() != null, ReportJlKfsxzssyjlbBsInfo::getZhuirsdH1Group2, bo.getZhuirsdH1Group2());
        lqw.eq(bo.getZhuirsdH1Group3() != null, ReportJlKfsxzssyjlbBsInfo::getZhuirsdH1Group3, bo.getZhuirsdH1Group3());
        lqw.eq(bo.getZhuirsdH2Group1() != null, ReportJlKfsxzssyjlbBsInfo::getZhuirsdH2Group1, bo.getZhuirsdH2Group1());
        lqw.eq(bo.getZhuirsdH2Group2() != null, ReportJlKfsxzssyjlbBsInfo::getZhuirsdH2Group2, bo.getZhuirsdH2Group2());
        lqw.eq(bo.getZhuirsdH2Group3() != null, ReportJlKfsxzssyjlbBsInfo::getZhuirsdH2Group3, bo.getZhuirsdH2Group3());
        lqw.eq(bo.getZhuirsdH3Group1() != null, ReportJlKfsxzssyjlbBsInfo::getZhuirsdH3Group1, bo.getZhuirsdH3Group1());
        lqw.eq(bo.getZhuirsdH3Group2() != null, ReportJlKfsxzssyjlbBsInfo::getZhuirsdH3Group2, bo.getZhuirsdH3Group2());
        lqw.eq(bo.getZhuirsdH3Group3() != null, ReportJlKfsxzssyjlbBsInfo::getZhuirsdH3Group3, bo.getZhuirsdH3Group3());
        lqw.eq(bo.getHanslhhGroup1Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhhGroup1Item1, bo.getHanslhhGroup1Item1());
        lqw.eq(bo.getHanslhhGroup1Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhhGroup1Item2, bo.getHanslhhGroup1Item2());
        lqw.eq(bo.getHanslhhGroup2Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhhGroup2Item1, bo.getHanslhhGroup2Item1());
        lqw.eq(bo.getHanslhhGroup2Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhhGroup2Item2, bo.getHanslhhGroup2Item2());
        lqw.eq(bo.getHanslhhGroup3Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhhGroup3Item1, bo.getHanslhhGroup3Item1());
        lqw.eq(bo.getHanslhhGroup3Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhhGroup3Item2, bo.getHanslhhGroup3Item2());
        lqw.eq(bo.getHanslhzlGroup1Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhzlGroup1Item1, bo.getHanslhzlGroup1Item1());
        lqw.eq(bo.getHanslhzlGroup1Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhzlGroup1Item2, bo.getHanslhzlGroup1Item2());
        lqw.eq(bo.getHanslhzlGroup2Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhzlGroup2Item1, bo.getHanslhzlGroup2Item1());
        lqw.eq(bo.getHanslhzlGroup2Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhzlGroup2Item2, bo.getHanslhzlGroup2Item2());
        lqw.eq(bo.getHanslhzlGroup3Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhzlGroup3Item1, bo.getHanslhzlGroup3Item1());
        lqw.eq(bo.getHanslhzlGroup3Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhzlGroup3Item2, bo.getHanslhzlGroup3Item2());
        lqw.eq(bo.getHanslhstzlGroup1Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhstzlGroup1Item1, bo.getHanslhstzlGroup1Item1());
        lqw.eq(bo.getHanslhstzlGroup1Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhstzlGroup1Item2, bo.getHanslhstzlGroup1Item2());
        lqw.eq(bo.getHanslhstzlGroup2Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhstzlGroup2Item1, bo.getHanslhstzlGroup2Item1());
        lqw.eq(bo.getHanslhstzlGroup2Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhstzlGroup2Item2, bo.getHanslhstzlGroup2Item2());
        lqw.eq(bo.getHanslhstzlGroup3Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhstzlGroup3Item1, bo.getHanslhstzlGroup3Item1());
        lqw.eq(bo.getHanslhstzlGroup3Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhstzlGroup3Item2, bo.getHanslhstzlGroup3Item2());
        lqw.eq(bo.getHanslhgtzlGroup1Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhgtzlGroup1Item1, bo.getHanslhgtzlGroup1Item1());
        lqw.eq(bo.getHanslhgtzlGroup1Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhgtzlGroup1Item2, bo.getHanslhgtzlGroup1Item2());
        lqw.eq(bo.getHanslhgtzlGroup2Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhgtzlGroup2Item1, bo.getHanslhgtzlGroup2Item1());
        lqw.eq(bo.getHanslhgtzlGroup2Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhgtzlGroup2Item2, bo.getHanslhgtzlGroup2Item2());
        lqw.eq(bo.getHanslhgtzlGroup3Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhgtzlGroup3Item1, bo.getHanslhgtzlGroup3Item1());
        lqw.eq(bo.getHanslhgtzlGroup3Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslhgtzlGroup3Item2, bo.getHanslhgtzlGroup3Item2());
        lqw.eq(bo.getHanslszlGroup1Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslszlGroup1Item1, bo.getHanslszlGroup1Item1());
        lqw.eq(bo.getHanslszlGroup1Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslszlGroup1Item2, bo.getHanslszlGroup1Item2());
        lqw.eq(bo.getHanslszlGroup2Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslszlGroup2Item1, bo.getHanslszlGroup2Item1());
        lqw.eq(bo.getHanslszlGroup2Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslszlGroup2Item2, bo.getHanslszlGroup2Item2());
        lqw.eq(bo.getHanslszlGroup3Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslszlGroup3Item1, bo.getHanslszlGroup3Item1());
        lqw.eq(bo.getHanslszlGroup3Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslszlGroup3Item2, bo.getHanslszlGroup3Item2());
        lqw.eq(bo.getHanslgtzlGroup1Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslgtzlGroup1Item1, bo.getHanslgtzlGroup1Item1());
        lqw.eq(bo.getHanslgtzlGroup1Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslgtzlGroup1Item2, bo.getHanslgtzlGroup1Item2());
        lqw.eq(bo.getHanslgtzlGroup2Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslgtzlGroup2Item1, bo.getHanslgtzlGroup2Item1());
        lqw.eq(bo.getHanslgtzlGroup2Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslgtzlGroup2Item2, bo.getHanslgtzlGroup2Item2());
        lqw.eq(bo.getHanslgtzlGroup3Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslgtzlGroup3Item1, bo.getHanslgtzlGroup3Item1());
        lqw.eq(bo.getHanslgtzlGroup3Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslgtzlGroup3Item2, bo.getHanslgtzlGroup3Item2());
        lqw.eq(bo.getHanslGroup1Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslGroup1Item1, bo.getHanslGroup1Item1());
        lqw.eq(bo.getHanslGroup1Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslGroup1Item2, bo.getHanslGroup1Item2());
        lqw.eq(bo.getHanslGroup2Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslGroup2Item1, bo.getHanslGroup2Item1());
        lqw.eq(bo.getHanslGroup2Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslGroup2Item2, bo.getHanslGroup2Item2());
        lqw.eq(bo.getHanslGroup3Item1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslGroup3Item1, bo.getHanslGroup3Item1());
        lqw.eq(bo.getHanslGroup3Item2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslGroup3Item2, bo.getHanslGroup3Item2());
        lqw.eq(bo.getHanslPjzGroup1() != null, ReportJlKfsxzssyjlbBsInfo::getHanslPjzGroup1, bo.getHanslPjzGroup1());
        lqw.eq(bo.getHanslPjzGroup2() != null, ReportJlKfsxzssyjlbBsInfo::getHanslPjzGroup2, bo.getHanslPjzGroup2());
        lqw.eq(bo.getHanslPjzGroup3() != null, ReportJlKfsxzssyjlbBsInfo::getHanslPjzGroup3, bo.getHanslPjzGroup3());
        lqw.eq(bo.getYex() != null, ReportJlKfsxzssyjlbBsInfo::getYex, bo.getYex());
        lqw.eq(bo.getSux() != null, ReportJlKfsxzssyjlbBsInfo::getSux, bo.getSux());
        lqw.eq(bo.getSuxzs() != null, ReportJlKfsxzssyjlbBsInfo::getSuxzs, bo.getSuxzs());
        return lqw;
    }

    /**
     * 新增矿粉塑性指数试验检测记录
     */
    @Override
    public Boolean insertByBo(ReportJlKfsxzssyjlbBsInfoBo bo) {
        ReportJlKfsxzssyjlbBsInfo add = BeanUtil.toBean(bo, ReportJlKfsxzssyjlbBsInfo.class);
        validEntityBeforeSave(add);
        boolean flag = baseMapper.insert(add) > 0;
        if (flag) {
            bo.setExcelId(add.getExcelId());
        }
        return flag;
    }

    /**
     * 修改矿粉塑性指数试验检测记录
     */
    @Override
    public Boolean updateByBo(ReportJlKfsxzssyjlbBsInfoBo bo) {
        ReportJlKfsxzssyjlbBsInfo update = BeanUtil.toBean(bo, ReportJlKfsxzssyjlbBsInfo.class);
        validEntityBeforeSave(update);
        return baseMapper.updateById(update) > 0;
    }

    /**
     * 保存前的数据校验
     */
    private void validEntityBeforeSave(ReportJlKfsxzssyjlbBsInfo entity){
        //TODO 做一些数据校验,如唯一约束
    }

    /**
     * 批量删除矿粉塑性指数试验检测记录
     */
    @Override
    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
        if(isValid){
            //TODO 做一些业务上的校验,判断是否需要校验
        }
        return baseMapper.deleteBatchIds(ids) > 0;
    }
}
